package com.qianfeng.openapi.monitor.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/5
 * @Time: 下午3:01
 */
@Component
public class SpringUtils implements ApplicationContextAware {

    static ApplicationContext ac  = null;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SpringUtils.ac = applicationContext;
    }

    public static ApplicationContext getAc() {
        return ac;
    }

    public static  Object getBean(String name){
        return SpringUtils.ac.getBean(name);
    }

    public static  Object getBean(Class clazz){
        return SpringUtils.ac.getBean(clazz);
    }
}
